package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface shopCarMapper {
    /**
     * 根据套餐id返回套餐
     *
     * @param intExact
     * @param currentId
     * @return
     */
    @Select("select * from shopping_cart where setmeal_id=#{setMealID} and user_id=#{currentId}")
    ShoppingCart selectBySetMealId(Integer setMealID, Long currentId);

    /**
     * 返回是否有相同种类的菜品
     * @param dishId
     * @param currentId
     * @param dishFlavor
     * @return
     */

    ShoppingCart select(ShoppingCart shoppingCart);

   void updateShop(ShoppingCart shoppingCart);



    @Insert("insert into shopping_cart (id,name,image, " +
            "user_id, dish_id, setmeal_id, dish_flavor," +
            " amount, create_time) VALUES (#{id},#{name},#{image},#{userId},#{dishId},#{setmealId}," +
            "#{dishFlavor},#{amount},#{createTime})")
    void insert(ShoppingCart build);
    @Select("select * from shopping_cart where user_id=#{id}")
    List<ShoppingCart> page(Long id);

    public void deleteOne(@Param("shoppingCartDTO") ShoppingCartDTO shoppingCartDTO,
                          @Param("userId") Long userId);

    void insertBatch(List<ShoppingCart> shoppingCartList);
}
